package com.itheima.day05_多态和内部类.develophomework02.homework03;

public class Test {
    public static void main(String[] args) {
        Vehicle v = new Car(4,5,7);
        v.getInfor();
        Car c = (Car)v;
        c.changeColor();

        Truck t = new Truck();
        t.setWeight(10);
        t.setWheels(8);
        t.setPayload(20);
        t.getInfor();
        t.carryGoods();

    }
}
class Vehicle{
    private int wheels;
    private double weight;

    public void getInfor(){
        System.out.println("这是一辆总重"+getWeight()+"有"+getWheels()+"个轮子的汽车");
    }

    public Vehicle() {
    }

    public Vehicle(int wheels, double weight) {
        this.wheels = wheels;
        this.weight = weight;
    }

    public int getWheels() {
        return wheels;
    }

    public void setWheels(int wheels) {
        this.wheels = wheels;
    }

    public double getWeight() {
        return weight;
    }

    public void setWeight(double weight) {
        this.weight = weight;
    }
}

interface ChangeColor{
    void changeColor();
}
interface CarryGoods{
    void carryGoods();
}

class Car extends Vehicle implements ChangeColor{
    private int loader;

    @Override
    public void getInfor() {
        System.out.println("总重"+getWeight()+","+getWheels()+"个轮子"+"载客量"+getLoader());
    }

    public int getLoader() {
        return loader;
    }

    public void setLoader(int loader) {
        this.loader = loader;
    }

    public Car() {
    }

    public Car(int wheels, double weight, int loader) {
        super(wheels, weight);
        this.loader = loader;
    }

    @Override
    public void changeColor() {
        System.out.println("红色的小车");
    }
}

class Truck extends Car implements CarryGoods{

    private double payload;

    @Override
    public void getInfor() {
        System.out.println("总重"+getWeight()+","+getWheels()+"个轮子"+"载货量"+getPayload());
    }

    public Truck() {
    }

    public Truck(int wheels, double weight, int loader) {
        super(wheels, weight, loader);
    }

    public double getPayload() {
        return payload;
    }

    public void setPayload(double payload) {
        this.payload = payload;
    }

    @Override
    public void carryGoods() {
        System.out.println("可以载货");
    }
}